const path = require('path');
const { merge } = require('webpack-merge')
const common = require('./webpack.common.js'); //引入公共配置
const HotModuleReplacementPlugin = require('webpack/lib/HotModuleReplacementPlugin')
console.log(process.env.METHOD)
module.exports = merge(common, {
    mode: "development",
    devtool: "eval-cheap-module-source-map",
    plugins: [
        new HotModuleReplacementPlugin(),
    ],
    optimization:{
        runtimeChunk: {
            name: 'runtime'
          }
    },
    devServer: { //开发服务器
        static: './dist',
        port: "9080",
        proxy: { //反向代理，根据需求自行修改
            "/api": {
                target: "http://127.0.0.1:1111",
                pathRewrite: {
                    "^/api": ""
                }
            },
        },
        historyApiFallback: {
            rewrites:[
                { from: /.*/g, to: '/index.html' },
            ]
        },
        open: true,  //打开浏览器
        // hot: true, //开启热更新功能
    },
});
